package com.colorful.insuranceproject.home;

import android.os.Bundle;
import android.os.Message;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.colorful.insuranceproject.R;
import com.colorful.insuranceproject.adapter.MessageAdapter;
import com.colorful.insuranceproject.base.PLEActivity;
import com.colorful.insuranceproject.bean.MessageBean;
import com.colorful.insuranceproject.request.HomeRequest;
import com.lovely3x.common.utils.Response;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by handsome-Bob on 2017/10/29.
 * <p>
 * 我的消息页面
 */
public class MessageActivity extends PLEActivity implements View.OnClickListener {

    MessageAdapter messageAdapter;

    @Bind(R.id.list_message)
    ListView lvMessage;

    @Bind(R.id.fl_fragment_list_empty_container)
    ViewGroup viewContainer;

    private static final int GET_MESSAGE_PAGE_dATA = 0X1;

    HomeRequest homeRequest;

    @Override
    protected int getContentView() {
        return R.layout.activity_message;
    }

    @Override
    protected void initViews() {
        super.initViews();
        ButterKnife.bind(this);
        setTitle(getString(R.string.mine_message));
    }

    @Override
    protected void onViewInitialized() {
        homeRequest = new HomeRequest(getHandler());
        messageAdapter = new MessageAdapter(MocoData(), mActivity);
        lvMessage.setAdapter(messageAdapter);

        onContentStatusChanged(EMPTY_CONTENT);
//        currentIndex = DEFAULT_POST_FIRST_PAGE;
//        getPageData();
    }

    private void getPageData() {
        if (homeRequest != null) {

        }
    }

    private List<MessageBean> MocoData() {
        List<MessageBean> bean = new ArrayList<>();
        bean.add(new MessageBean("天气色等烟雨"));
        bean.add(new MessageBean("而我在等你"));
        bean.add(new MessageBean("炊烟袅袅升起"));
        bean.add(new MessageBean("隔江千万里"));
        return bean;
    }

    @Override
    public void onBeginRefresh() {

    }

    @Override
    public void onBeginLoadMore() {

    }


    @Override
    protected void handleResponseMessage(Message msg, Response response) {
        super.handleResponseMessage(msg, response);
        switch (msg.what) {
            case GET_MESSAGE_PAGE_dATA:

                break;
        }
    }

    @Override
    public void restoreInstanceOnCreateBefore(@NonNull Bundle savedInstance) {

    }

    @Override
    public void restoreInstanceOnCreateAfter(@NonNull Bundle savedInstance) {

    }

    @Override
    protected ViewGroup getEmptyContainerView() {
        return viewContainer;
    }

    @Override
    public void onClick(View v) {
        onContentStatusChanged(LOADING_CONTENT);
        currentIndex = DEFAULT_POST_FIRST_PAGE;
        getPageData();
    }
}
